libxl: band-aid for functions which return literal "-1"
authorIan Jackson <ian.jackson@eu.citrix.com>
Wed, 26 Jan 2011 11:58:45 +0000 (11:58 +0000)
committerIan Jackson <ian.jackson@eu.citrix.com>
Wed, 26 Jan 2011 11:58:45 +0000 (11:58 +0000)
Many libxl functions erroneously return "-1" on error, rather than
some ERROR_* value.

To deal with this, invent a new ERROR_NONSPECIFIC "-1" which indicates
that "the function which generated this error code is broken".

Fix up the one we care about for forthcoming duplicate domain
detection (libxl_name_to_domid) and the others following the same
pattern nearby; leave the rest for post-4.1.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
tools/libxl/libxl.h
tools/libxl/libxl_utils.c

index 1160de3c8cbc4d507590dd27267557aeac876db0..d608e99ca4fda40d215137f7edc1f526c2cd513e 100644 (file)
@@ -232,12 +232,13 @@ typedef struct {
 } libxl_domain_suspend_info;
 
 enum {
-    ERROR_VERSION = -1,
-    ERROR_FAIL = -2,
-    ERROR_NI = -3,
-    ERROR_NOMEM = -4,
-    ERROR_INVAL = -5,
-    ERROR_BADFAIL = -6,
+    ERROR_NONSPECIFIC = -1,
+    ERROR_VERSION = -2,
+    ERROR_FAIL = -3,
+    ERROR_NI = -4,
+    ERROR_NOMEM = -5,
+    ERROR_INVAL = -6,
+    ERROR_BADFAIL = -7,
 };
 
 #define LIBXL_VERSION 0
index 64c884fd77c3d2c9b32f7bf81061cf35630821e1..a44f8af3e4c6420beb5a2145f185c73f55eccfe1 100644 (file)
@@ -93,7 +93,7 @@ int libxl_name_to_domid(libxl_ctx *ctx, const char *name,
     int i, nb_domains;
     char *domname;
     libxl_dominfo *dominfo;
-    int ret = -1;
+    int ret = ERROR_INVAL;
 
     dominfo = libxl_list_domain(ctx, &nb_domains);
     if (!dominfo)
@@ -142,7 +142,7 @@ int libxl_name_to_cpupoolid(libxl_ctx *ctx, const char *name,
     int i, nb_pools;
     char *poolname;
     libxl_cpupoolinfo *poolinfo;
-    int ret = -1;
+    int ret = ERROR_INVAL;
 
     poolinfo = libxl_list_cpupool(ctx, &nb_pools);
     if (!poolinfo)
@@ -171,7 +171,7 @@ int libxl_name_to_schedid(libxl_ctx *ctx, const char *name)
         if (strcmp(name, schedid_name[i].name) == 0)
             return schedid_name[i].id;
 
-    return -1;
+    return ERROR_INVAL;
 }
 
 char *libxl_schedid_to_name(libxl_ctx *ctx, int schedid)
@@ -287,7 +287,7 @@ int libxl_string_to_phystype(libxl_ctx *ctx, char *s, libxl_disk_phystype *physt
     } else if (!strcmp(s, "tap")) {
         p = strchr(s, ':');
         if (!p) {
-            rc = -1;
+            rc = ERROR_INVAL;
             goto out;
         }
         p++;